package com.ee.chat.cps.admin.controller.datareport;

import com.ee.chat.common.bean.Result;
import com.ee.chat.cps.admin.service.IReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author AppiJ
 * @Date 2020/3/30 14:31
 */
@RestController
@RequestMapping("dataReport/report")
public class ReportController {
    private Logger log = LoggerFactory.getLogger(ReportController.class);

    @Resource
    IReportService reportService;

    /**
     * 获取我的报表列表
     * @Author AppiJ
     * @Date 2020/3/30 15:11
     * @param date  搜索日期
     * @return
     */
    @RequestMapping("list")
    public Result list(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit, String date){
        try{
            return reportService.list(request, page, limit, date);
        }catch (Exception e){
            log.error("【获取我的报表列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 获取报表明细列表
     * @Author AppiJ
     * @Date 2020/4/1 14:59
     * @param time  日期时间
     * @param type  类型
     * @return
     */
    @RequestMapping("detailList")
    public Result detailList(HttpServletRequest request, String time, Integer type,
                             @RequestParam Integer page, @RequestParam Integer limit){
        try {
            return reportService.detailList(request, time, type, page, limit);
        } catch (Exception e){
            log.error("【获取报表明细列表错误】", e);
        }
        return Result.returnFailure();
    }
}
